<?php
/**
 * 周舟 hzboye010@163.com
 * addby sublime snippets
 * 商品和店铺优惠 测试类
 */

namespace app\test\controller;

use app\utils\BoyeService;
use app\test\controller\Ava;

class Product extends Ava{
    //获取套餐信息
    public function packageDetail(){
        if(IS_AJAX){
          $data = [
            'package_id' =>I('post.package_id',''),
            'api_ver'   =>$this->api_ver,
            'notify_id' =>$this->notify_id,
            'alg'       =>$this->alg,
            'type'      =>'BY_Product_packageDetail',
          ];
          $service = new BoyeService();
          $result = $service->callRemote("",$data,true);
          return $this->parseResult($result);

        }else{
          $this->assign('type','BY_Product_packageDetail');
          $this->assign('field',[
            ['api_ver',$this->api_ver,LL('need-mark api version')],
            ['package_id',1,LL('need-mark package-ID')],
          ]);
          echo $this->display('ava/test');
        }
    }
    //获取全部商品服务
    public function getServices(){
        if(IS_AJAX){
          $data = [
            'api_ver'   =>$this->api_ver,
            'notify_id' =>$this->notify_id,
            'alg'       =>$this->alg,
            'type'      =>'BY_Product_getServices',
          ];
          $service = new BoyeService();
          $result = $service->callRemote("",$data,true);
          return $this->parseResult($result);

        }else{
          $this->assign('type','BY_Product_getServices');
          $this->assign('field',[
            ['api_ver',$this->api_ver,LL('need-mark api version')],
          ]);
          echo $this->display('ava/test');
        }
    }
    //搜索词获取
    public function searchWords(){
        if(IS_AJAX){
          $data = [
            'uid'       =>I('post.uid',''),
            'sort'      =>I('post.sort',''),
            'number'    =>I('post.number',''),
            'api_ver'   =>$this->api_ver,
            'notify_id' =>$this->notify_id,
            'alg'       =>$this->alg,
            'type'      =>'BY_Product_searchWords',
          ];
          $service = new BoyeService();
          $result = $service->callRemote("",$data,true);
          return $this->parseResult($result);

        }else{
          $this->assign('type','BY_Product_searchWords');
          $this->assign('field',[
            ['api_ver',$this->api_ver,LL('need-mark api version')],
            ['sort',1,LL('need-mark tag-type')],
            ['number',10,LL('searchWords count')],
            ['uid',50,LL('user ID')],
          ]);
          echo $this->display('ava/test');
        }
    }
    //妈妈赠 - 评价
    public function commentGift(){
        if(IS_AJAX){
            $data = [
            'uid'         => I('post.uid',''),
            'pid'         => I('post.pid',''),
            'content'     => I('post.content',''),
            'attachments' => I('post.attachments',''),
            'send'        => I('post.send',''),
            'score1'      => I('post.score1',''),
            'score2'      => I('post.score2',''),
            'score3'      => I('post.score3',''),
            'api_ver'   => $this->api_ver,
            'notify_id' => $this->notify_id,
            'alg'       => $this->alg,
            'type'      => 'BY_Product_commentGift',
            ];
            $service = new BoyeService();
            $result  = $service->callRemote("",$data,true);
            echo $this->parseResult($result);
        }else{
            $this->assign('type','BY_Product_commentGift');
            $this->assign('field',[
              ['api_ver',101,LL('need-mark api version')],
              ['uid','156',LL('need-mark owner user ID')],
              ['pid','429',LL('need-mark product ID')],
              ['content','nice goods',LL('need-mark content')],
              ['attachments','',L('attachments')],
              ['send','100',L('send')],
              ['score1','1',L('score1')],
              ['score2','2',L('score2')],
              ['score3','3',L('score3')],
            ]);
            echo $this -> display('ava/test');
        }
    }
    //妈妈赠 - 收藏 - 分页
    public function queryFavGift(){
        if(IS_AJAX){
            $data = [
                'uid'       => I('post.uid',''),
                'page_no'   => I('post.page_no',''),
                'page_size' => I('post.page_size',''),
                'max_img'   => I('post.max_img',''),
                'api_ver'   => $this->api_ver,
                'notify_id' => $this->notify_id,
                'alg'       => $this->alg,
                'type'      => 'BY_Product_queryFavGift',
            ];
            $service = new BoyeService();
            $result  = $service->callRemote("",$data,true);
            echo $this->parseResult($result);
        }else{
            $this->assign('type','BY_Product_queryFavGift');
            $this->assign('field',[
                ['api_ver',$this->api_ver,LL('need-mark api version')],
                ['uid','42',LL('need-mark owner user ID')],
                ['page_no','1',L('page')],
                ['page_size','10',LL('page size')],
                ['max_img','3',L('max-img')],
            ]);
            echo $this -> display('ava/test');
        }
    }
    //妈妈赠 - 类目获取
    public function giftCate(){
        if(IS_AJAX){
            $data = [
                'api_ver'   => $this->api_ver,
                'notify_id' => $this->notify_id,
                'alg'       => $this->alg,
                'type'      => 'BY_Product_giftCate',
            ];
            $service = new BoyeService();
            $result  = $service->callRemote("",$data,true);
            echo $this->parseResult($result);
        }else{
            $this->assign('type','BY_Product_giftCate');
            $this->assign('field',[
                ['api_ver',$this->api_ver,LL('need-mark api version')],
            ]);
            echo $this -> display('ava/test');
        }
    }
    //妈妈赠 - 发货
    public function express(){
        if(IS_AJAX){
            $data = [
                'uid'          => I('post.uid',''),
                'pid'          => I('post.pid',''),
                'express_no'   => I('post.express_no',''),
                'express_code' => I('post.express_code',''),
                'api_ver'   => $this->api_ver,
                'notify_id' => $this->notify_id,
                'alg'       => $this->alg,
                'type'      => 'BY_Product_express',
            ];
            $service = new BoyeService();
            $result  = $service->callRemote("",$data,true);
            echo $this->parseResult($result);
        }else{
            $this->assign('type','BY_Product_express');
            $this->assign('field',[
                ['api_ver',$this->api_ver,LL('need-mark api version')],
                ['uid','42',LL('owner user ID')],
                ['pid','320',LL('product ID')],
                ['express_no','229919837458',LL('express-number')],
                ['express_code','6006',LL('express-code')],
            ]);
            echo $this -> display('ava/test');
        }
    }
    //妈妈赠列表 - 分页
    public function listGift(){
        if(IS_AJAX){
            $data = [
                'uid'       => I('post.uid',''),
                'to_uid'    => I('post.to_uid',''),
                'name'      => I('post.name',''),
                'zone_id'   => I('post.zone_id',''),
                'cate_id'   => I('post.cate_id',''),
                'page_no'   => I('post.page_no',''),
                'page_size' => I('post.page_size',''),
                'order'     => I('post.order',''),
                'api_ver'   => $this->api_ver,
                'notify_id' => $this->notify_id,
                'alg'       => $this->alg,
                'type'      => 'BY_Product_listGift',
            ];
            $service = new BoyeService();
            $result  = $service->callRemote("",$data,true);
            echo $this->parseResult($result);
        }else{
            $this->assign('type','BY_Product_listGift');
            $this->assign('field',[
                ['api_ver',$this->api_ver,LL('need-mark api version')],
                ['uid','',LL('user ID')],
                ['to_uid','',LL('winner user ID')],
                ['name','',LL('product name')],
                ['zone_id','',LL('product zone ID')],
                ['cate_id','',LL('product cate ID')],
                ['page_no','1',L('page')],
                ['page_size','10',L('product-page-size')],
                ['order','19',L('product-mmz-order')],
            ]);
            echo $this -> display('ava/test');
        }
    }
    //妈妈赠 - 发布
    public function addGift(){
        if(IS_AJAX){
            $data = [
                'uid'         => I('post.uid',''),
                'title'       => I('post.title',''),
                'message'     => I('post.message',''),
                'cate_id'     => I('post.cate_id',''),
                'template'    => I('post.template',''),
                'main_img'    => I('post.main_img',''),
                'show_imgs'   => I('post.show_imgs',''),
                // 'country'     => I('post.country',''),
                // 'province'    => I('post.province',''),
                // 'city'        => I('post.city',''),
                'zone_id'     => I('post.zone_id',''),
                'address'     => I('post.address',''),
                'api_ver'     => $this->api_ver,
                'notify_id'   => $this->notify_id,
                'alg'         => $this->alg,
                'type'        => 'BY_Product_addGift',
            ];
            $service = new BoyeService();
            $result  = $service->callRemote("",$data,true);
            echo $this->parseResult($result);
        }else{
            $this->assign('type','BY_Product_addGift');
            $this->assign('field',[
                ['api_ver',101,LL('need-mark api version')],
                ['uid',42,LL('need-mark user ID')],
                ['title','我亲爱的祖国',LL('need-mark title')],
                ['message','国家转让',LL('need-mark message')],
                ['cate_id',0,L('product-cate-id')],
                ['template',0,L('template-id')],
                ['show_imgs','',L('attachments')],
                ['main_img','',L('the-main-img-id')],
                ['zone_id','110101',L('the-area-id')],
                // ['country','中国',L('country')],
                // ['province','浙江',L('province')],
                // ['city','杭州',L('city')],
                // ['address','下沙智慧谷',L('address')],
            ]);
            echo $this -> display('ava/test');
        }
    }
    //收藏商品
    public function favorites(){
        if(IS_AJAX){
            $data = [
                'uid'            => I('uid',0),
                'pid'            => I('post.pid',0),
                'fav_type'       => I('post.fav_type',0),
                'favorite_value' => I('favorite_value',0),
                'api_ver'        => $this->api_ver,
                'notify_id'      => $this->notify_id,
                'alg'            => $this->alg,
                'type'           => 'BY_Product_favorites',
            ];
            $service = new BoyeService();
            $result  = $service->callRemote("",$data,true);
            echo $this->parseResult($result);
        }else{
            $this->assign('type','BY_Product_favorites');
            $this->assign('field',[
                ['api_ver',$this->api_ver,LL('need-mark api version')],
                ['pid',156,LL('need-mark product ID')],
                ['uid',42,LL('need-mark user ID')],
                ['favorite_value',1,LL('need-mark product-fav-val')],
                ['fav_type',1,L('fav-type')],
            ]);
            echo $this -> display('ava/test');
        }
    }
    /**
     * 商品评论 分页
     * @return [type] [description]
     */
    public function comment(){
        if(IS_AJAX){
            $data = [
                'pid'       => I('post.pid',0),
                'page_no'   => I('post.page_no',1),
                'page_size' => I('post.page_size',10),
                'max_img'   => I('post.max_img',3),
                'api_ver'   => $this->api_ver,
                'notify_id' => $this->notify_id,
                'alg'       => $this->alg,
                'type'      => 'BY_Product_comment',
            ];
            $service = new BoyeService();
            $result  = $service->callRemote("",$data,true);
            echo $this->parseResult($result);
        }else{
            $this->assign('type','BY_Product_comment');
            $this->assign('field',[
                ['api_ver',$this->api_ver,LL('need-mark api version')],
                ['pid',1,LL('need-mark product ID')],
                ['page_no',1,L('page')],
                ['page_size',10,LL('page size')],
                ['max_img',3,LL('max img')],
            ]);
            echo $this -> display('ava/test');
        }
    }
    //查询店铺优惠
    public function storeInfo(){
        if(IS_AJAX){
            $data = [
                'store_id'       => I('store_id',0),
                'api_ver'        => $this->api_ver,
                'notify_id'      => $this->notify_id,
                'alg'            => $this->alg,
                'type'           => 'BY_StorePromotion_getInfo',
            ];
            $service = new BoyeService();
            $result  = $service->callRemote("",$data,true);
            echo $this->parseResult($result);
        }else{
            $this->assign('type','BY_StorePromotion_getInfo');
            $this->assign('field',[
                ['api_ver',$this->api_ver,LL('need-mark api version')],
                ['store_id',2,LL('need-mark store ID')],
            ]);
            echo $this -> display('ava/test');
        }
    }

    //获取收藏商品 - 分页
    public function getFavorites(){

        if(IS_AJAX){
            $data = [
                'uid'       => I('post.uid',0),
                'page_no'   => I('post.page_no',1),
                'page_size' => I('post.page_size',10),
                'api_ver'   =>$this->api_ver,
                'notify_id' =>$this->notify_id,
                'alg'       =>$this->alg,
                'type'      => 'BY_Product_getFavorites',
            ];
            $service = new BoyeService();
            $result = $service->callRemote("",$data,true);
            echo $this->parseResult($result);
        }else{
            $this->assign('type','BY_Product_getFavorites');
            $this->assign('field',[
                ['api_ver',$this->api_ver,LL('need-mark api version')],
                ['uid',42,LL('need-mark user ID')],
                ['page_no',1,L('page')],
                ['page_size',10,L('product-page-size')],
            ]);
            echo $this->display('ava/test');
        }

    }

    //查询商品咨询
    public function queryFaq(){
        if(IS_AJAX){
            $data = [
                'pid'       => I('post.pid',''),
                'page_no'   => I('post.page_no',''),
                'page_size' => I('post.page_size',''),
                'fresh'     => I('post.fresh',''),
                'api_ver'   => $this->api_ver,
                'notify_id' => $this->notify_id,
                'alg'       => $this->alg,
                'type'      => 'BY_Product_queryFaq',
            ];
            $service = new BoyeService();
            $result = $service->callRemote("",$data,true);
            echo $this->parseResult($result);
        }else{
            $this->assign('type','BY_Product_queryFaq');
            $this->assign('field',[
                ['api_ver',$this->api_ver,LL('need-mark api version')],
                ['pid',57,LL('need-mark product ID')],
                ['page_no',1,L('page')],
                ['page_size',10,L('product-page-size')],
                ['fresh',0,L('if-fresh')],
            ]);
            echo $this -> display('ava/test');
        }
    }
    //商品咨询详情
    public function detailFaq(){
        if(IS_AJAX){
            $data = [
                'id'        => I('post.id',0),
                'api_ver'   => $this->api_ver,
                'notify_id' => $this->notify_id,
                'alg'       => $this->alg,
                'type'      => 'BY_Product_detailFaq',
            ];
            $service = new BoyeService();
            $result = $service->callRemote("",$data,true);
            echo $this->parseResult($result);
        }else{
            $this->assign('type','BY_Product_detailFaq');
            $this->assign('field',[
                ['api_ver',$this->api_ver,LL('need-mark api version')],
                ['id',31,LL('need-mark ask ID')],
            ]);
            echo $this -> display('ava/test');
        }
    }

    //保存商品咨询
    public function ask(){
        if(IS_AJAX){
            $data = [
                'pid'          => I('post.pid',0),
                'ask_content'  => I('post.ask_content',''),
                'ask_uid'      => I('post.ask_uid',0),
                // 'ask_username' => I('post.ask_username',''),
                'api_ver'      => $this->api_ver,
                'notify_id'    => $this->notify_id,
                'alg'          => $this->alg,
                'type'         => 'BY_Product_ask',
            ];
            $service = new BoyeService();
            $result = $service->callRemote("",$data,true);
            echo $this->parseResult($result);
        }else{
            $this->assign('type','BY_Product_ask');
            $this->assign('field',[
                ['api_ver',$this->api_ver,LL('need-mark api version')],
                ['pid',156,LL('need-mark product ID')],
                ['ask_content','ask test',LL('need-mark ask content')],
                ['ask_uid',42,LL('need-mark ask user ID')],
                // ['ask_username','rainbow',LL('need-mark ask username')],
            ]);
            echo $this -> display('ava/test');
        }
    }
    //二手商品申请
    public function applyGift(){
        if(IS_POST){
            $data = [
                'uid'       => I('post.uid',''),
                'pid'       => I('post.pid',0),
                'reason'    => I('post.reason',''),
                'address_id'=> I('post.address_id',''),
                'api_ver'   => $this->api_ver,
                'notify_id' => $this->notify_id,
                'alg'       => $this->alg,
                'type'      => 'BY_Product_applyGift',
            ];
            $service = new BoyeService();
            $result = $service->callRemote("",$data,true);
            echo $this->parseResult($result);
        }else{
            $this->assign('type','BY_Product_applyGift');
            $this->assign('field',[
                ['api_ver','100',LL('need-mark api version')],
                ['pid','320',LL('need-mark product ID')],
                ['uid','50',LL('user ID')],
                ['reason','LOVE IT !',L('reason')],
                ['address_id','145',LL('address ID')],
            ]);
            echo $this -> display('ava/test');
        }
    }
    //二手商品申请列表 - 分页
    public function applyList(){
        if(IS_POST){
            $data = [
                'pid'       => I('post.pid',0),
                'page_no'   => I('post.page_no',''),
                'page_size' => I('post.page_size',''),
                'fresh'     => I('post.fresh',''),
                'api_ver'   => $this->api_ver,
                'notify_id' => $this->notify_id,
                'alg'       => $this->alg,
                'type'      => 'BY_Product_applyList',
            ];
            $service = new BoyeService();
            $result = $service->callRemote("",$data,true);
            echo $this->parseResult($result);
        }else{
            $this->assign('type','BY_Product_applyList');
            $this->assign('field',[
                ['api_ver','100',LL('need-mark api version')],
                ['pid','320',LL('need-mark product ID')],
                ['page_no','1',L('page')],
                ['page_size','10',L('product-page-size')],
                ['fresh','0',L('if-fresh')],
            ]);
            echo $this -> display('ava/test');
        }
    }
    //二手商品选择赠送
    public function chose(){
        if(IS_POST){
            $data = [
                'apply_id'  => I('post.apply_id',''),
                'uid'       => I('post.uid',''),
                'pid'       => I('post.pid',''),
                'api_ver'   => $this->api_ver,
                'notify_id' => $this->notify_id,
                'alg'       => $this->alg,
                'type'      => 'BY_Product_chose',
            ];
            $service = new BoyeService();
            $result = $service->callRemote("",$data,true);
            echo $this->parseResult($result);
        }else{
            $this->assign('type','BY_Product_chose');
            $this->assign('field',[
                ['api_ver','100',LL('need-mark api version')],
                ['pid','320',LL('need-mark product ID')],
                ['apply_id','10',LL('need-mark apply-id')],
                ['uid','17',LL('need-mark owner user ID')],
            ]);
            echo $this -> display('ava/test');
        }
    }
    //二手商品详情
    public function detailGift(){
        if(IS_POST){
            $data = [
                'pid'       => I('post.pid',''),
                'uid'       => I('post.uid',''),
                'page_size' => I('post.page_size',''),
                'api_ver'   => $this->api_ver,
                'notify_id' => $this->notify_id,
                'alg'       => $this->alg,
                'type'      => 'BY_Product_detailGift',
            ];
            $service = new BoyeService();
            $result = $service->callRemote("",$data,true);
            echo $this->parseResult($result);
        }else{
            $this->assign('type','BY_Product_detailGift');
            $this->assign('field',[
                ['api_ver','100',LL('need-mark api version')],
                ['pid','320',LL('need-mark product ID')],
                ['uid','17',L('product-uid')],
                ['page_size','10',LL('page size')],
            ]);
            echo $this -> display('ava/test');
        }
    }
    //商品详情
    public function detail(){
        if(IS_POST){
            $data = [
                'pid'       => I('post.pid',''),
                'uid'       => I('post.uid',''),
                'gid'       => I('post.gid',''),
                'api_ver'   => $this->api_ver,
                'notify_id' => $this->notify_id,
                'alg'       => $this->alg,
                'type'      => 'BY_Product_detail',
            ];
            $service = new BoyeService();
            $result = $service->callRemote("",$data,true);
            echo $this->parseResult($result);
        }else{
            $this->assign('type','BY_Product_detail');
            $this->assign('field',[
                ['api_ver','100',LL('need-mark api version')],
                ['pid','1',LL('need-mark product ID')],
                ['uid','143',L('product-uid')],
                ['gid','',L('product-gid')],
            ]);
            echo $this -> display('ava/test');
        }
    }

    //分组分页查询
    public function queryByGroup(){
        if(IS_AJAX){
            $data = [
                'group_id'  =>I('post.group_id',''),
                'cate_id'   =>I('post.cate_id',''),
                'page_no'   =>I('post.page_no',''),
                'page_size' =>I('post.page_size',''),
                'order'     =>I('post.order',''),
                'api_ver'   => $this->api_ver,
                'notify_id' => $this->notify_id,
                'alg'       => $this->alg,
                'type'      => 'BY_Product_queryByGroup',
            ];
            $service = new BoyeService();
            $result = $service->callRemote("",$data,true);
            echo $this->parseResult($result);
        }else{
            $this->assign('type','BY_Product_queryByGroup');
            $this->assign('field',[
                ['api_ver','100',LL('need-mark api version')],
                ['group_id','15',LL('need-mark product-group-id')],
                ['cate_id','',LL('cate ID')],
                ['page_no','1',L('page')],
                ['page_size','10',L('product-page-size')],
                ['order','10',L('product-group-order')],
            ]);
            echo $this -> display('ava/test');
        }
    }

    //分页查询
    public function query(){
        if(IS_AJAX){
            $data = array(
                // 'cate_parent' => I('post.cate_parent',""),
                'name'        => I('post.name',''),
                'cate_id'     => I('post.cate_id',''),
                'zone_id'     => I('post.zone_id',''),
                'service_id'     => I('post.service_id',''),
                'origin_country' => I('post.origin_country',''),
                'special'     => I('post.special',''),
                'page_no'     => I('post.page_no',''),
                'page_size'   => I('post.page_size',''),
                'order'       => I('post.order',''),
                'min_cost'    => I('post.min_cost',''),
                'max_cost'    => I('post.max_cost',''),
                'api_ver'     => $this->api_ver,
                'notify_id'   => $this->notify_id,
                'alg'         => $this->alg,
                'type'        => 'BY_Product_query',
            );
            $service = new BoyeService();
            $result = $service->callRemote("",$data,true);
            echo $this->parseResult($result);
        }else{
            $this->assign('type','BY_Product_query');
            $this->assign('field',[
                ['api_ver','100',LL('need-mark api version')],
                // ['cate_parent','',LL('product cate-parent ID')],
                ['name','',LL('product name')],
                ['cate_id','',LL('product cate ID')],
                ['zone_id','',LL('product zone ID')],
                ['service_id','',LL('product service ID')],
                ['origin_country','',LL('country ID')],
                ['special','',L('product-special-ID')],
                ['page_no','1',L('page')],
                ['page_size','10',L('product-page-size')],
                ['order','10',L('product-order')],
                ['min_cost','',LL('min price')],
                ['max_cost','',LL('max price')],
            ]);
            echo $this -> display('ava/test');
        }
    }
}